import 'dart:convert';
import 'package:base_flutter/base_flutter.dart';
import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/material.dart';
import 'package:ls_work/a_message/models/message_row_entity.dart';
import 'package:ls_work/res/gaps.dart';
import 'package:ls_work/res/styles.dart';
import 'package:ls_work/ui/service_order/service_order_detail_page.dart';
import 'package:ls_work/util/ext_utils.dart';
import 'package:ls_work/widgets/load_image.dart';

class MessagerowView extends StatelessWidget {
  final MessageRowInfo? info;
  MessagerowView({Key? key, this.info});
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(15, 20, 15, 10),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              LoadImage(
                '${info?.iconUrl??""}',
                width: 45,
                height: 45,
              ),
              Gaps.hGap12,
              Text(
                '${info?.typeName??""}',
                style: TextStyles.textDark18,
              ),
            ],
          ),
          Container(
            alignment: Alignment.centerRight,
            padding: EdgeInsets.only(right: 10),
            child: Text(
              '${info?.createdDate??''}',
              style: TextStyles.textGray14,
            ),
          ),
          Gaps.vGap12,
          Container(
            margin: EdgeInsets.fromLTRB(5, 0, 5, 0),
            padding: EdgeInsets.all(15),
            width: ScreenUtil.getScreenW(context),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(8),
            ),
            child: Row(
              children: [
                Text(
                  jsonDecode(info?.body??"")['content'],
                ).setWeight(1),
              ],
            ),
          ).onTap((){
            if(info?.srcBizId=='MSG.SERVE_ORDER'&&info?.tagTwo!=null){
              Go().push(ServiceOrderDetailPage(showDetail: false, orderId: info?.tagTwo.toStringOrNull()??""));
            }
          }),
        ],
      ),
    );
  }
}
